package 双Value类型

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object intersection {
    //求交集
    def main(args: Array[String]): Unit = {

        val config: SparkConf = new SparkConf().setMaster("local[*]").setAppName("WordCount")

        val sc = new SparkContext(config)

        val listRDD: RDD[Int] = sc.makeRDD(List(1, 2, 3, 4, 5, 6))

        val ArrayRDD: RDD[Int] = sc.parallelize(Array(5, 6, 7))

        val intersectionRDD: RDD[Int] = listRDD.intersection(ArrayRDD)

        intersectionRDD.collect().foreach(println)

        val intersectionRDD2: RDD[Int] = ArrayRDD.intersection(listRDD)

        intersectionRDD2.collect().foreach(println)


    }

}
